package com.jsmile.cloud.msgcenter.zf.strategy.notify;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.jsmile.cloud.msgcenter.zf.enums.AliNotifyTypeEnum;
import com.jsmile.cloud.msgcenter.zf.req.ali.AliNotifyResponse;
import com.jsmile.cloud.msgcenter.zf.req.ali.AliUserInfoBizContent;
import com.jsmile.cloud.msgcenter.zf.strategy.interfaces.IAlilNotify;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class UserInfoNotifyStrategy implements IAlilNotify {

    @Override
    public String getNotifyType() {
        return AliNotifyTypeEnum.TRADE_STATUS.getType();
    }

    /**
     * 用户敏感信息申请回调
     *
     * @param data
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String excute(String data) {
        log.info("用户敏感信息申请回调参数：{}", data);
        String requset = data.replace("\\", "").replace("\"{", "{").replace("}\"", "}");
        AliNotifyResponse<AliUserInfoBizContent> notifyResponse = JSON.parseObject(requset, new TypeReference<AliNotifyResponse<AliUserInfoBizContent>>() {});
        return SUCCESS;
    }

}
